package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper //通用mapper
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {
    @Insert("insert into t_checkgroup_checkitem values(#{id},#{checkitemId})")
    void addCheckGroupAndCheckItemIds(@Param("id") Integer id, @Param("checkitemId") Integer checkitemId);

    @Delete("delete from t_checkgroup_checkitem where CHECKGROUP_ID = #{groupId}")
    void relieveByGroupId(@Param("groupId") Integer groupId);

    @Select("select tc.name,tc.sex,AGE,tc.remark " +
            "from t_checkgroup_checkitem tcc,t_checkitem tc " +
            "where tcc.CHECKITEM_ID = tc.ID " +
            "and tc.is_delete=0 " +
            "and tcc.CHECKGROUP_ID = #{id}")
    List<CheckItem> findCheckItemsByGroupId(@Param("id") Integer id);
}
